<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="../../vue.js"></script>
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 用 v-for 指令基于一个数组来渲染一个列表 -->
      <ul>
        <li v-for="item,index in users">
          <p>姓名:{{item.name}}</p>
          <p>年龄:{{item.age}}</p>
        </li>
      </ul>

      <!-- 遍历对象 -->
      <div v-for="value,key of person">{{key}}:{{value}}</div>

      <!-- 遍历字符串 -->
      <div v-for="char,index of str">{{index}}:{{char}}</div>

      <!-- 遍历指定的次数 -->
      <div v-for="num,index of 5">{{index}}:{{num}}</div>
    </div>
    <script>
      const vm = new Vue({
        el: '#app',
        data() {
          return {
            users: [
              {
                id: 1,
                name: 'xiaozhang',
                age: 18,
              },
              {
                id: 2,
                name: 'xiaowang',
                age: 28,
              },
              {
                id: 3,
                name: 'xiaoli',
                age: 38,
              },
            ],
            person: {
              id: 3,
              name: 'xiaoli',
              age: 38,
            },
            str: 'sdzgvfdbher',
          };
        },
      });
    </script>
  </body>
</html>
